<template>
	<div class="vue_app">
		<!--头部-->
		<my-header :title="'消息详情'" :hasTitle="true" :hasBack="true" ></my-header>
		<!--<div style="height: 3rem;"></div>-->
		<!--头部-->
		<div class="aui-content top_div message_detail">
			<div class="message_title" style="text-align: left;">
				<h2 v-if="data">{{data.title}}</h2>
				<p v-if="data">发布日期：{{data.publishTmStr}}</p>
			</div>
			<div class="message_con" style="text-align: left;">
				<img :src="data.imgUrl"  v-if="data"/>
				<p v-html="data.content" v-if="data">{{data.content}}</p>
			</div>
		</div>
	</div>
</template>

<script>
import MyHeader from "../../header";
import {getNews, changeNews} from '../../../api/wxh/getData.js';
import {reFreshUserInfo} from '../../../utils/WXH/login.js';
import { Toast } from '../../../utils/toast.js';
import {mapMutations, mapActions, mapGetters} from "vuex";
import axios from 'axios';
import {zxBase,zxSessionId} from '../../../api/zxApi.js';


export default {
	data () {
		return {
			data: null,
			num: null
		}
	}
	,
	async mounted () {
		await this.getUserInfo();
		this.initData();
		this.num = this.$route.query.newsId;
		console.log(7989989898989898989)
	}
	,
	computed:{
		...mapGetters('wxh', [
			'sessionId',
			'login'
		])
	}
	,
	components:{
		"my-header":MyHeader
	},
	methods: {
		...mapActions('wxh', [
		  'getUserInfo'
		])
		,
		...mapMutations('wxh', [
		  'USER_INFO',
		  'ClEAR_SESSIONID',
		  'LOGO_OUT',
		  'LOGO_IN',
		  'CLEAR_INFO'
		])
		,
		changeNews(num){
//			http://172.19.6.152:33004/messageVue/updateReadStatus
			let params = {
	    		rid: num  //是否分頁  false不分頁
	    	};
    		let config = {
	        	url:window.api.customer_host+"/messageVue/updateReadStatus",
	        	method: 'POST',
	        	headers: {'sessionId': this.sessionId},
	        	data:params
           	};
           	axios(config).then((res)=>{
           		console.log('刷新消息');	
           })
		},
		getNewsList(){
			let params = {
	    		isPage:"false",//是否分頁  false不分頁
	    		enterpriseCode:window.api.enterpriseCode
	    	};

//      		window.api.local_host
//				let url = "http://172.19.5.131:33004/messageVue/findMessageList"
//      		let config = {
//	            	url:window.api.local_host+"/messageVue/findMessageList",
//	            	method: 'Post',
//	            	headers: {'sessionId': this.sessionId},
//	            	data:params
//	           	};
           	let config = {
            	url:window.api.customer_host+"/messageVue/findMessageList",
            	method: 'POST',
            	headers: {'sessionId': this.sessionId},
            	data:params
           	};
           axios(config).then((res)=>{
//         		console.log(res.data.data[0].results,'saddddd')
	           	if(res.data.returncode == 0) {
					Toast({
					  message: req.errmsg,
					  type: 'fail',
					  duration: 2000
					});
					return
				}
				for(let i of res.data.data[0].results) {
					if(i.rid == this.num )
					this.data = i;	
				}
				console.log(this.data, this.num)
				this.changeNews(this.num);
           })
		},
		async initData() {
			//调用個人中心的方法刷新用户信息 防止vuex用户信息失效
			reFreshUserInfo(this);
			//请求消息列表
			this.getNewsList();
		}
	}
}
</script>
<style scoped="scoped">
	.vue_app{
		width: 100%;
	    height: 100%;
	    display: flex;
	    flex-direction: column;
	    align-items: center;
	    justify-content: space-between;
	}
	.message_detail{
		flex: 1;
		overflow-y: auto;
		width: 100%;
	}
	.message_detail .message_title {
	     padding-bottom:0; 
	}
</style>